home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 75 / Mac Magazin CD 75.iso / macware / Red Bird's Quick Scripts / Browser Chomper / Browser Chomper.as next >
Encoding:
Text File  |  2000-07-28  |  6.0 KB  |  133 lines  |  [TEXT/ToyS]

  1. (*
  2. Browser Chomper 0.8.1:  Gets ride of annoying browser files.
  3. Copyright (C) 1999-2000 Gordon Worley.
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  8.  
  9. For a copy of the GNU General Public License, visit <http://www.gnu.org/> or write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, Boston, MA 02111-1307, USA.
  10.  
  11. To contact me, please visit my Web site at <http://www.rbisland.cx/> or e-mail me at <redbird@rbisland.cx>.
  12.  
  13. History:
  14.  
  15. 0.8.1 - Commented out section that starts iCab deletion since iCab takes care of doing this all internally.  Uncomment only if you want to use Browser Chomper for some reason instead (like forgetting the sites you have told iCab to refuse to take cookies from).
  16. 0.8 - Added partial support for IE; I can't find the cookie file(s).  Also, change variable names to have underscores, reflecing my new coding style.
  17. 0.7 - Added support for multiuser versions of Netscape.  Before, only upgraded 3.x users' main users were affected.  As a performance tweek, you may wish to comment out the new multiuser code or the older single user code, depending on which one is actually needed (i.e. if it used to work fine, and you don't have multiple users, comment out the new code).
  18. 0.6 - Added support for iCab and more code changes to accomidate multiple browsers.  Support for more browsers soon, I hope.
  19. 0.4 - Code made more robust.  A couple other small changes, which don't really matter because no one but me has seen this code until now.
  20. 0.3.2 - Uses 'system folder' constant, so that it will always find the blessed folder, regardless of its name.
  21. 0.3.1 - Name changed from 'Cookie Mage' to 'Browser Chomper'.
  22. 0.3 - Gets ride of more than just cookies.  Added support for Global History and Chache folder deletion.  Maybe I should change the name???
  23. 0.2 - Checks to see if a browser exist that will work with this script before trying anything.
  24. 0.1.5 - Messed it up with some experimental code.
  25. 0.1 - Added error handling for deletion.
  26. 0.0 - Pressed record button.  Initial release.  :-)
  27. *)
  28.  
  29. on run {}
  30.     set failed to true
  31.     tell application "Finder"
  32.         activate --Put this script in the background so you can keep working B-)
  33.         if startup disk's system folder's folder "Preferences"'s folder "Netscape ƒ" exists then --This sees if you have a version of Netscape installed that this script works with
  34.             my do_Netscape()
  35.             set failed to false
  36.         end if
  37.         if startup disk's system folder's folder "Preferences"'s folder "Netscape Users" exists then
  38.             my do_MultiNetscape()
  39.             set failed to false
  40.         end if
  41.         --this next part is commented out because iCab can do this internally.  Uncomment only if you don't want iCab to take care of this task and want Browser Chomper to.
  42.         (*if startup disk's system folder's folder "Preferences"'s folder "iCab Preferences" exists then --same deal but with iCab
  43.             my do_iCab()
  44.             set failed to false
  45.         end if*)
  46.         if startup disk's system folder's folder "Preferences"'s folder "Explorer" exists then --finds if IE is there
  47.             my do_IE()
  48.             set failed to false
  49.         end if
  50.         if failed then
  51.             beep
  52.             display dialog "Oops, it looks like you don't have a compatible version of Netscape, IE, or iCab installed." with icon 0 buttons {"OK"} default button 1
  53.         else
  54.             empty trash
  55.         end if
  56.     end tell
  57. end run
  58.  
  59. on do_Netscape()
  60.     tell application "Finder"
  61.         --MagicCookie deletion
  62.         try
  63.             delete startup disk's system folder's folder "Preferences"'s folder "Netscape ƒ"'s file "MagicCookie"
  64.         end try
  65.         --Get ride of Gloabl History
  66.         --Not always a good idea; forgets your recently visited links
  67.         try
  68.             delete startup disk's system folder's folder "Preferences"'s folder "Netscape ƒ"'s file "Global History"
  69.         end try
  70.         --Clear the cache while we're at it
  71.         try
  72.             delete startup disk's system folder's folder "Preferences"'s folder "Netscape ƒ"'s folder "Cache ƒ"
  73.         end try
  74.     end tell
  75. end do_Netscape
  76.  
  77. on do_MultiNetscape()
  78.     tell application "Finder"
  79.         set user_folder to startup disk's system folder's folder "Preferences"'s folder "Netscape Users"
  80.         set the_users to list folder user_folder
  81.         repeat with a_user in the_users
  82.             --MagicCookie deletion
  83.             try
  84.                 delete alias ((user_folder as string) & a_user & ":MagicCookie")
  85.             end try
  86.             --Get ride of Gloabl History
  87.             --Not always a good idea; forgets your recently visited links
  88.             try
  89.                 delete alias ((user_folder as string) & a_user & ":Global History")
  90.             end try
  91.             --Clear the cache while we're at it
  92.             try
  93.                 delete alias ((user_folder as string) & a_user & ":Cache ƒ")
  94.             end try
  95.         end repeat
  96.     end tell
  97. end do_MultiNetscape
  98.  
  99. on do_iCab()
  100.     tell application "Finder"
  101.         --MagicCookie deletion
  102.         try
  103.             delete startup disk's system folder's folder "Preferences"'s folder "iCab Preferences"'s file "iCab Cookies"
  104.         end try
  105.         --Get ride of History
  106.         --Not always a good idea; forgets your recently visited links
  107.         try
  108.             delete startup disk's system folder's folder "Preferences"'s folder "iCab Preferences"'s file "iCab History"
  109.         end try
  110.         --Clear the cache while we're at it
  111.         try
  112.             delete startup disk's system folder's folder "Preferences"'s folder "iCab Preferences"'s folder "iCab Cache"
  113.         end try
  114.     end tell
  115. end do_iCab
  116.  
  117. on do_IE()
  118.     tell application "Finder"
  119.         --MagicCookie deletion
  120.         try
  121.             --cookie in Internet Prefs.  Need help deleting just the cookies out of this file. <redbird@rbisland.cx>
  122.         end try
  123.         --Get ride of History
  124.         --Not always a good idea; forgets your recently visited links
  125.         try
  126.             delete startup disk's system folder's folder "Preferences"'s folder "Explorer"'s file "History.html"
  127.         end try
  128.         --Clear the cache while we're at it
  129.         try
  130.             delete startup disk's system folder's folder "Preferences"'s folder "MS Internet Cache"
  131.         end try
  132.     end tell
  133. end do_IE